import { AdHorizontal } from "./AdHorizontal";
import { AdVertical } from "./AdVertical";
import { BannerOptions } from "./BannerOptions";
import { NativeSize } from "./NativeSize";
import { Vec2 } from 'cc';
import { Debug } from "../utils/Debug";
export class NativeLR {
    public static width: number = 720;
    public static height: number = 300;
}
export class NativeTB {
    public static width: number = 720;
    public static height: number = 630;
}
export class NativePIC {
    public static width: number = 720;
    public static height: number = 525;
}

export default class NativeOptions extends BannerOptions {


    public CurrentSize: NativeSize = NativeSize.LR;

    constructor(horizontal: AdHorizontal, vertical: AdVertical, offset: Vec2, left: number, top: number) {
        super();
        this.Horizontal = horizontal;
        this.Vertical = vertical;
        this.Top = top;
        this.Left = left;
        this.Offset = offset;
    }


    public get width() {
        if (this.CurrentSize == NativeSize.TB) {
            return NativeTB.width;
        }
        else if (this.CurrentSize == NativeSize.PIC) {
            return NativePIC.width;
        }
        return NativeLR.width;
    }

    public get height() {
        if (this.CurrentSize == NativeSize.TB) {
            return NativeTB.height;
        }
        else if (this.CurrentSize == NativeSize.PIC) {
            return NativePIC.height;
        }
        return NativeLR.height;
    }

    public GetStyle(sysinfo: any): { left: number, top: number, width: number } {
        let windowHeight = sysinfo.screenHeight;
        let windowWidth = sysinfo.screenWidth;
        let top = 0;
        let left = 0;
        Debug.log(`1-----显示Native horizontal ${this.Horizontal}  vertical ${this.Vertical} windowWidth:${windowWidth}  windowHeight:${windowHeight}  `);
        // Debugger.LogInfo("2-----显示banner horizontal {0}  vertical {1}", horizontal==AdHorizontal.CENTER, vertical==AdVertical.TOP);
        switch (this.Vertical) {
            case AdVertical.TOP:
                top = 0;
                break;
            case AdVertical.CENTER:
                top = (windowHeight - this.height) / 2;
                break;
            case AdVertical.BOTTOM:
                top = windowHeight - this.height;
                break;
            case AdVertical.CUSTOM:
            default:
                top = this.Top;
                break;
        }
        switch (this.Horizontal) {
            case AdHorizontal.LEFT:
                left = 0;
                break;
            case AdHorizontal.CENTER:
                left = (windowWidth - this.width) / 2;
                break;
            case AdHorizontal.RIGHT:
                left = windowWidth - this.width;
                break;
            case AdHorizontal.CUSTOM:
            default:
                left = this.Left;
                break;
        }

        Debug.log(`"Native Option  left:${left} top:${top}"`);

        var style =
        {
            left: left + this.Offset.x,
            top: top + this.Offset.y,
            width: this.width
        };
        return style;
    }

}
